package com.cskaoyan.market.controller;

import com.cskaoyan.market.service.MarketConfigService;
import com.cskaoyan.market.util.ResponseUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.util.Map;


@RestController
@RequestMapping("/admin/config")
public class AdminConfigController extends HttpServlet {
    @Autowired
    private MarketConfigService configService;

    @Autowired
    ObjectMapper objectMapper;


    @PostMapping("mall")
    private Object updateMall(@RequestBody Map<String, Object> map) {
        configService.update(map);
        return ResponseUtil.ok();
    }
    @PostMapping("wx")
    private Object updateWx(@RequestBody Map<String, Object> map) {
        configService.update(map);
        return ResponseUtil.ok();
    }
    @PostMapping("order")
    private Object updateOrder(@RequestBody Map<String, Object> map) {
        configService.update(map);
        return ResponseUtil.ok();
    }
    @PostMapping("express")
    private Object updateExpress(@RequestBody Map<String, Object> map){
        configService.update(map);
        return ResponseUtil.ok();
    }

    @GetMapping("mall")
    private Object mall() {
        Map<String, String> data = configService.mall();
        return ResponseUtil.ok(data);
    }

    @GetMapping("wx")
    private Object wx() {
        Map<String, String> data = configService.wx();
        return ResponseUtil.ok(data);
    }

    @GetMapping("order")
    private Object order() {
        Map<String, String> data = configService.order();
        return ResponseUtil.ok(data);
    }

    @GetMapping("express")
    private Object express() {
        Map<String, String> data = configService.express();
        return ResponseUtil.ok(data);
    }
}

